import 'package:flutter/material.dart';
import 'package:get/get.dart';
import 'package:practice_app/pages/book_shop/view.dart';
import 'package:practice_app/pages/home/logic.dart';
import 'package:practice_app/pages/home/view.dart';
import 'package:practice_app/pages/my_center/view.dart';
import 'logic.dart';
import 'state.dart';

class ApplicationPage extends StatelessWidget {
  ApplicationPage({super.key});

  final ApplicationLogic logic = Get.put(ApplicationLogic());
  final ApplicationState state = Get.find<ApplicationLogic>().state;

  List list=[
    HomePage(),
    BookShopPage(),
    MyCenterPage()
  ];

  @override
  Widget build(BuildContext context) {
    return Obx(()=>Scaffold(
      bottomNavigationBar: BottomNavigationBar(
        currentIndex:  state.currentIndex.value,
        onTap: (int index) {
          state.currentIndex.value = index;
        },
        items:const <BottomNavigationBarItem>[
          BottomNavigationBarItem(label: '首页',icon: Icon(Icons.home)),
          BottomNavigationBarItem(label: '书籍',icon: Icon(Icons.book)),
          BottomNavigationBarItem(label: '我的',icon: Icon(Icons.perm_identity)),
        ],
      ),
      body:list[ state.currentIndex.value] ,
    ));
  }
}
